package com.softwarerusher.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.softwarerusher.daoImpl.BookDAO;
import com.softwarerusher.daoImpl.manageDAO;
import com.softwarerusher.model.TBook;

public class netshoptodayhot extends ActionSupport implements RequestAware,SessionAware{

	private int totalnum = 0 ;
	private  int requestpagenum;
    private Map<String,Object> request;
    private Map<String,Object> session;
    private List<TBook> bookList;
    static private int pagesize = 4;
    public String todayhot()
    {
    	
    	List<TBook> result = BookDAO.rank1();
    	
    	bookList = BookDAO.paging(result, 1, pagesize);
    	if(result.size()%pagesize==0)
    	{
    	    totalnum = result.size()/pagesize;
    	}else{
    		totalnum = result.size()/pagesize+1;
    	}
    	request.put("totalnum", Integer.toString(totalnum));
    	request.put("currentpage", "1");
    	request.put("pagesize", pagesize);
    	return "success";
    }
    public String page()
    {
    	List<TBook> result = BookDAO.rank1();
    	
    	bookList = BookDAO.paging(result, requestpagenum, pagesize);
    	if(result.size()%pagesize==0)
    	{
    	    totalnum = result.size()/pagesize;
    	}else{
    		totalnum = result.size()/pagesize+1;
    	}
    	request.put("totalnum", Integer.toString(totalnum));
    	request.put("currentpage", String.valueOf(requestpagenum));
    	request.put("pagesize", pagesize);
    	return "success";
    }
	public Map<String, Object> getRequest() {
		return request;
	}
	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}
	public Map<String, Object> getSession() {
		return session;
	}
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	public List<TBook> getBookList() {
		return bookList;
	}
	public void setBookList(List<TBook> bookList) {
		this.bookList = bookList;
	}
	public int getRequestpagenum() {
		return requestpagenum;
	}
	public void setRequestpagenum(int requestpagenum) {
		this.requestpagenum = requestpagenum;
	}
	public int getTotalnum() {
		return totalnum;
	}
	public void setTotalnum(int totalnum) {
		this.totalnum = totalnum;
	}
}
